﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using OgilvyOne.BLL;

public partial class admin_manager_adminrule : AdminBasePage
{
    string idlist;
    protected void Page_Load(object sender, EventArgs e)
    {

        if (IsPostBack)
        {
            idlist = "";
            bool BxsChkd = false;
            for (int i = 1; i < GridView1.Rows.Count; i++)
            {
                CheckBox checkbox = (CheckBox)GridView1.Rows[i].FindControl("DeleteThis");
                //CheckBox checkbox1 = (CheckBox)GridView1.Rows[i].Cells[1].Controls[0];
                //string id = GridView1.Rows[i].Cells[1].ClientID;
                //CheckBox ChkBxItem = (CheckBox)GridView1.Rows[i].FindControl(id);            
                if (checkbox != null && checkbox.Checked)
                {
                    BxsChkd = true;
                    System.Web.UI.WebControls.Label lable = (System.Web.UI.WebControls.Label)GridView1.Rows[i].Cells[0].FindControl("Label1");
                    idlist = idlist + lable.Text + ",";
                }
            }
            if (BxsChkd)
            {
                idlist = idlist.Substring(0, idlist.LastIndexOf(","));
            }
        }
        else
        {
            header.Text = new ColumnBll().LayeridSysColumnNaiv(Layerid);
            BindData();
        }
    }  
    //删除
    protected void LinkButton2_Click(object sender, EventArgs e)
    {
        
        this.PopedomValidate(Layerid,DEL);        
        string idlists = idlist;
        if (idlists.Trim().Length == 0)
            return;
        new RoleBll().Deletelist(idlists);
        BindData();
    }
    //数据绑定
    public void BindData()
    {
        DataSet ds = new RoleBll().GetList("");
        GridView1.DataSource = ds;
        GridView1.DataBind();
    }
    protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        GridView1.PageIndex = e.NewPageIndex;
        BindData();
    }
    protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
    {
        GridViewRow gvr = GridView1.BottomPagerRow;
        System.Web.UI.WebControls.TextBox textbox = (System.Web.UI.WebControls.TextBox)gvr.FindControl("txtNewPageIndex");
        System.Web.UI.WebControls.Label lblcount = (System.Web.UI.WebControls.Label)gvr.FindControl("lblPageCount");
        int index;
        if (int.TryParse(textbox.Text, out index))
        {
            if (index >= 1)
            {
                GridView1.PageIndex = index - 1;
            }
            else
                GridView1.PageIndex = 0;
        }
        else
        {
            ClientScript.RegisterClientScriptBlock(Page.GetType(), Guid.NewGuid().ToString(), "alert('输入的数字非法')");
        }
        BindData();
    }
}
